package com.huawei.gamebox.service.welfare.gift.node;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.Space;
import com.huawei.gamebox.service.welfare.gift.bean.GiftCardBean;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import java.util.ArrayList;
import java.util.List;
import o.cgu;
import o.chz;
import o.cih;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.exp.j;
import o.eyh;
import o.fce;
import o.ll;

public class GiftNode extends BaseGiftNode {
    private List<GiftCardBean> ॱॱ = new ArrayList();
    private a ᐝ;

    class a extends SafeBroadcastReceiver {
        final /* synthetic */ GiftNode ˎ;

        private a(GiftNode giftNode) {
            this.ˎ = giftNode;
        }

        public void onReceiveMsg(Context context, Intent intent) {
            String action = intent.getAction();
            if (Logger.ˎ()) {
                Logger.ˏ("GiftNode", "receive " + action);
            }
            if ("com.huawei.gamebox.refreshBuoyGiftCard".equals(action)) {
                String stringExtra = intent.getStringExtra("refresh.observer.id");
                String stringExtra2 = intent.getStringExtra("refresh.observer.value");
                if (this.ˎ.ॱॱ.size() > 0) {
                    for (GiftCardBean giftCardBean : this.ˎ.ॱॱ) {
                        if (!dof.ॱ(stringExtra) && stringExtra.equals(giftCardBean.ᐝ()) && 2 != giftCardBean.ʼ()) {
                            giftCardBean.ˎ(2);
                            giftCardBean.ˏ(stringExtra2);
                            if (Logger.ˎ()) {
                                Logger.ˏ("GiftNode", "refresh GiftCard");
                            }
                            eyh.ˏ();
                            return;
                        }
                    }
                }
            }
        }
    }

    public GiftNode(Context context) {
        super(context);
    }

    public void ॱˊ() {
        super.ॱˊ();
        ॱॱ();
    }

    protected void ॱॱ() {
        this.ᐝ = new a();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("com.huawei.gamebox.refreshBuoyGiftCard");
        ll.ˏ(ContentManager.getInstant().getContext().getApplicationContext()).ˏ(this.ᐝ, intentFilter);
        if (Logger.ˎ()) {
            Logger.ˏ("GiftNode", "registerReceiver");
        }
    }

    public boolean ˊ(ViewGroup viewGroup, ViewGroup viewGroup2) {
        LayoutParams layoutParams = new LinearLayout.LayoutParams(cgu.ˋ(), -1);
        LayoutParams layoutParams2 = new LinearLayout.LayoutParams(-1, -2);
        layoutParams2.weight = 1.0f;
        int ˏ = ˏ();
        for (int i = 0; i < ˏ; i++) {
            if (i != 0) {
                viewGroup.addView(new Space(this.ॱ), layoutParams);
            }
            View ˊ = ˊ(this.ˊ);
            if (ˊ != null) {
                cih o_fce = new fce(this.ॱ, false, ʻ());
                o_fce.ˏ(ˊ);
                ˊ(o_fce);
                viewGroup.addView(ˊ, layoutParams2);
            }
        }
        return true;
    }

    public boolean ॱ(chz o_chz, ViewGroup viewGroup) {
        int ˏ = ˏ();
        this.ˏ = o_chz.ˏ;
        for (int i = 0; i < ˏ; i++) {
            cih ˎ = ˎ(i);
            if (ˎ instanceof fce) {
                CardBean ˋ = o_chz.ˋ(i);
                if (ˋ instanceof GiftCardBean) {
                    ˋ.ˋˋ(String.valueOf(this.ˏ));
                    GiftCardBean giftCardBean = (GiftCardBean) ˋ;
                    this.ॱॱ.add(giftCardBean);
                    ˎ.ˎ(giftCardBean, viewGroup);
                    ˎ.ˉ().setVisibility(0);
                } else {
                    ˎ.ˉ().setVisibility(8);
                }
            }
        }
        return true;
    }

    protected View ˊ(LayoutInflater layoutInflater) {
        View view = null;
        if (layoutInflater != null) {
            view = (RelativeLayout) layoutInflater.inflate(j.ـ, null);
            if (view != null) {
                int ˎ = ˎ();
                view.setPadding(ˎ, 0, ˎ, 0);
            }
        }
        return view;
    }

    public void ॱˎ() {
        super.ॱˎ();
        ʼ();
    }

    private void ʼ() {
        if (this.ᐝ != null) {
            ll.ˏ(ContentManager.getInstant().getContext().getApplicationContext()).ˋ(this.ᐝ);
            if (Logger.ˎ()) {
                Logger.ˏ("GiftNode", "unRegisterReceiver");
            }
        }
    }
}
